package com.play.trading_test.controller;

import com.play.trading_test.config.CacheUtil;
import com.play.trading_test.mq.MessageProducer;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/index/v1/")
public class IndexController {

    @Resource
    private CacheUtil cacheUtil;

    @Resource
    private MessageProducer messageProducer;


    @GetMapping("/mqSend")
    public String mqSend(String message) {
        messageProducer.sendMessage("TEST_TOPIC", message);
        return "success";
    }

    @GetMapping("/cacheData")
    public String cacheData(String value) {
        cacheUtil.set("TEST_CACHE", value);
        return "success";
    }


    @GetMapping("/getCacheData")
    public Object getCacheData() {
        return cacheUtil.get("TEST_CACHE");
    }

}
